using UnityEngine;
using System.Collections;

public class CGameScene: CBaseScene
{
    public CTargetTimeProperty m_cTargetSpawnProperty;
    public CTargetTimeProperty m_cTargetDeactiveProperty;
	public CScoreList m_cScoreList;
	public CEffectList m_cEffectList;
    // Use this for initialization
    void Start()
    {
		CGlobalMgr.Instance.TargetSpawnMgr.TargetSpawnProperty = m_cTargetSpawnProperty;
        CGlobalMgr.Instance.TargetSpawnMgr.TargetDeactiveProperty = m_cTargetDeactiveProperty;
		CGlobalMgr.Instance.HUDMgr.ScoreList = m_cScoreList;
		CGlobalMgr.Instance.EffectMgr.EffectList = m_cEffectList;
		CGlobalMgr.Instance.MissionMgr.eGameState = CMissionMgr.E_GAMESTATE.eLOADING;
    }

	// Update is called once per frame
	void Update()
	{
		switch (CGlobalMgr.Instance.MissionMgr.eGameState)
		{
			case CMissionMgr.E_GAMESTATE.eLOADING:
				{
					CGlobalMgr.Instance.MissionMgr.eGameState = CMissionMgr.E_GAMESTATE.ePLAYING;
					_StartGame();
				}
				break;
			case CMissionMgr.E_GAMESTATE.ePLAYING:
				{
					_UpdatePlaying();
				}
				break;
			case CMissionMgr.E_GAMESTATE.eEND:
				{
					CGlobalMgr.Instance.MissionMgr.eGameState = CMissionMgr.E_GAMESTATE.eLOADING;
					Application.LoadLevel((int)E_SCENE.eMENU);
				}
				break;
		}

		if (true == Input.GetKey("escape"))
		{
			Application.Quit();
		}
	}
	void _StartGame()
	{
		CGlobalMgr.Instance.MissionMgr.StartGame();
		CGlobalMgr.Instance.IntersectMgr.StartGame();
		CGlobalMgr.Instance.TargetSpawnMgr.StartGame();
		CGlobalMgr.Instance.HUDMgr.StartGame();
	}

	void _UpdatePlaying()
	{
		CGlobalMgr.Instance.MissionMgr.UpdatePlaying();
		CGlobalMgr.Instance.IntersectMgr.UpdatePlaying();
		CGlobalMgr.Instance.TargetSpawnMgr.UpdatePlaying();
	}
}
